Skip to contentSkip to conversation

Change in openvpn[master]: Avoid SIGUR1 to SIGHUP when the configuration is read from stdin

Openvpn-devel In review plaisthos (Code Review) 3 participants 10 messages Mar 4, 2024 – Sep 17, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1709564073000.Icfc179490d6821e22d14817941fb0bad667c713f@...2715...

#1 lore raw

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/533?usp=email

to review the following change.

Change subject: Avoid SIGUR1 to SIGHUP when the configuration is read from stdin
......................................................................

Avoid SIGUR1 to SIGHUP when the configuration is read from stdin

If the configuration is read from stdin, we cannot reread the configuration as stdin provides the configuration only once. So whenever we hit the "close_context usr1 to hup" logic, the OpenVPN process will fail as tries to restart with an empty configuration.

Change-Id Icfc179490d6821e22d14817941fb0bad667c713f

---
M src/openvpn/openvpn.c

1 file changed, 5 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/33/533/1

src/openvpn/openvpn.c +5 -3
index 874facf..4d1437d 100644
@@ -32,6 +32,7 @@
 #include "multi.h"
 #include "win32.h"
 #include "platform.h"
+#include "string.h"
 
 #include "memdbg.h"
 
@@ -60,9 +61,10 @@
 
     /* set point-to-point mode */
     c->mode = CM_P2P;
-
-    /* initialize tunnel instance */
-    init_instance_handle_signals(c, c->es, CC_HARD_USR1_TO_HUP);
+    /* initialize tunnel instance, avoid SIGHUP when config is stdin since
+     * reading the config from stdin will not work */
+    bool stdin_config = c->options.config && (strcmp(c->options.config, "stdin") == 0);
+    init_instance_handle_signals(c, c->es, stdin_config ? 0 : CC_HARD_USR1_TO_HUP);
     if (IS_SIG(c))
     {
         return;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/533?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icfc179490d6821e22d14817941fb0bad667c713f
Gerrit-Change-Number: 533
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/533?usp=email )

Change subject: Avoid SIGUR1 to SIGHUP when the configuration is read from stdin
......................................................................

Patch Set 1:

(1 comment)

Commit Message:

http://gerrit.openvpn.net/c/openvpn/+/533/comment/8488b519_2420d9dd :
PS1, Line 11: "close_context usr1 to hup" logic, the OpenVPN process will fail as tries
Please add a short explanation of when this logic might be hit. It is completely unclear to me from the code how you might hit this (especially since both HUP and USR1 are blocked during init_instance). Something with management?

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/533?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icfc179490d6821e22d14817941fb0bad667c713f
Gerrit-Change-Number: 533
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Mon, 11 Mar 2024 15:09:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/533?usp=email )

Change subject: Avoid SIGUR1 to SIGHUP when the configuration is read from stdin
......................................................................

Patch Set 1: Code-Review-1

(1 comment)

Commit Message:

http://gerrit.openvpn.net/c/openvpn/+/533/comment/2cfbe3af_29c12353 :
PS1, Line 7: Avoid SIGUR1 to SIGHUP when the configuration is read from stdin Typo -> "SIGUSR1"

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/533?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icfc179490d6821e22d14817941fb0bad667c713f
Gerrit-Change-Number: 533
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Tue, 12 Mar 2024 16:38:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#4 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: Avoid SIGUSR1 to SIGHUP when the configuration is read from stdin

In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello flichtenheld,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/533?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Code-Review-1 by flichtenheld

Change subject: Avoid SIGUSR1 to SIGHUP when the configuration is read from stdin
......................................................................

Avoid SIGUSR1 to SIGHUP when the configuration is read from stdin

If the configuration is read from stdin, we cannot reread the configuration as stdin provides the configuration only once. So whenever we hit the "close_context usr1 to hup" logic, the OpenVPN process will fail as tries to restart with an empty configuration.

While OpenVPN tries to block USR1 from normal unix signal, I have observed cases in my app which sends USR1 from management interface where the CC_HARD_USR1_TO_HUP logic is trigger and breaking the OpenVPN process.

Change-Id Icfc179490d6821e22d14817941fb0bad667c713f

---
M src/openvpn/openvpn.c

1 file changed, 5 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/33/533/2

src/openvpn/openvpn.c +5 -3
index 0e85ebc..a55dde6 100644
@@ -32,6 +32,7 @@
 #include "multi.h"
 #include "win32.h"
 #include "platform.h"
+#include "string.h"
 
 #include "memdbg.h"
 
@@ -60,9 +61,10 @@
 
     /* set point-to-point mode */
     c->mode = CM_P2P;
-
-    /* initialize tunnel instance */
-    init_instance_handle_signals(c, c->es, CC_HARD_USR1_TO_HUP);
+    /* initialize tunnel instance, avoid SIGHUP when config is stdin since
+     * reading the config from stdin will not work */
+    bool stdin_config = c->options.config && (strcmp(c->options.config, "stdin") == 0);
+    init_instance_handle_signals(c, c->es, stdin_config ? 0 : CC_HARD_USR1_TO_HUP);
     if (IS_SIG(c))
     {
         return;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/533?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icfc179490d6821e22d14817941fb0bad667c713f
Gerrit-Change-Number: 533
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#5 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: Avoid SIGUSR1 to SIGHUP when the configuration is read from stdin

In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/533?usp=email )

Change subject: Avoid SIGUSR1 to SIGHUP when the configuration is read from stdin
......................................................................

Patch Set 3: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/533?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icfc179490d6821e22d14817941fb0bad667c713f
Gerrit-Change-Number: 533
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Wed, 10 Jul 2024 16:14:10 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#6 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: Avoid SIGUSR1 to SIGHUP when the configuration is read from stdin

In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/533?usp=email )

Change subject: Avoid SIGUSR1 to SIGHUP when the configuration is read from stdin
......................................................................

Patch Set 3:

(2 comments)

Commit Message:

http://gerrit.openvpn.net/c/openvpn/+/533/comment/0584d87f_10f34ade :
PS1, Line 7: Avoid SIGUR1 to SIGHUP when the configuration is read from stdin

Quoted 1 line

Typo -> "SIGUSR1"

Done

http://gerrit.openvpn.net/c/openvpn/+/533/comment/457ac179_ec7f95d4 :
PS1, Line 11: "close_context usr1 to hup" logic, the OpenVPN process will fail as tries

Quoted 1 line

Please add a short explanation of when this logic might be hit. […]

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/533?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icfc179490d6821e22d14817941fb0bad667c713f
Gerrit-Change-Number: 533
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Fri, 19 Jul 2024 13:09:06 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Gerrit-MessageType: comment

#7 lore raw

PATCH v3 1/1 Avoid SIGUSR1 to SIGHUP when the configuration is read from stdin

In reply to a message not in the archive

From: Arne Schwabe <[email protected]...>

If the configuration is read from stdin, we cannot reread the configuration as stdin provides the configuration only once. So whenever we hit the "close_context usr1 to hup" logic, the OpenVPN process will fail as tries to restart with an empty configuration.

While OpenVPN tries to block USR1 from normal unix signal, I have observed cases in my app which sends USR1 from management interface where the CC_HARD_USR1_TO_HUP logic is trigger and breaking the OpenVPN process.

Change-Id Icfc179490d6821e22d14817941fb0bad667c713f

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/533
This mail reflects revision 3 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>

src/openvpn/openvpn.c +5 -3
index 0e85ebc..a55dde6 100644
@@ -32,6 +32,7 @@
 #include "multi.h"
 #include "win32.h"
 #include "platform.h"
+#include "string.h"
 
 #include "memdbg.h"
 
@@ -60,9 +61,10 @@
 
     /* set point-to-point mode */
     c->mode = CM_P2P;
-
-    /* initialize tunnel instance */
-    init_instance_handle_signals(c, c->es, CC_HARD_USR1_TO_HUP);
+    /* initialize tunnel instance, avoid SIGHUP when config is stdin since
+     * reading the config from stdin will not work */
+    bool stdin_config = c->options.config && (strcmp(c->options.config, "stdin") == 0);
+    init_instance_handle_signals(c, c->es, stdin_config ? 0 : CC_HARD_USR1_TO_HUP);
     if (IS_SIG(c))
     {
         return;
#8 lore raw

[Openvpn-devel] [PATCH applied] Re: Avoid SIGUSR1 to SIGHUP remapping when the configuration is read from stdin

I haven't tested this "for real", but the explanation makes sense and the change is trivial enough. I have word-smithed the Subject: and also the comment line a bit.

Your patch has been applied to the master branch.

(Not really a issue on "non Android", it seems, and that one builds on top of master only - so not applying to release/2.6)

commit b620025b9570a3d66ad3598dc22aa1b07c90fa31 (master)

Author: Arne Schwabe
Date:   Fri Jul 19 15:10:16 2024 +0200
     Avoid SIGUSR1 to SIGHUP remapping when the configuration is read from stdin

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Frank Lichtenheld <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg28941.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#9 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: Avoid SIGUSR1 to SIGHUP remapping when the configuration is read from...

In reply to a message not in the archive

cron2 has uploaded a new patch set (#4) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/533?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld

Change subject: Avoid SIGUSR1 to SIGHUP remapping when the configuration is read from stdin
......................................................................

Avoid SIGUSR1 to SIGHUP remapping when the configuration is read from stdin

If the configuration is read from stdin, we cannot reread the configuration as stdin provides the configuration only once. So whenever we hit the "close_context usr1 to hup" logic, the OpenVPN process will fail as tries to restart with an empty configuration.

While OpenVPN tries to block USR1 from normal unix signal, I have observed cases in my app which sends USR1 from management interface where the CC_HARD_USR1_TO_HUP logic is trigger and breaking the OpenVPN process.

Change-Id Icfc179490d6821e22d14817941fb0bad667c713f

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28941.html

---
M src/openvpn/openvpn.c

1 file changed, 5 insertions(+), 3 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/33/533/4

src/openvpn/openvpn.c +5 -3
index 0e85ebc..16147b7 100644
@@ -32,6 +32,7 @@
 #include "multi.h"
 #include "win32.h"
 #include "platform.h"
+#include "string.h"
 
 #include "memdbg.h"
 
@@ -60,9 +61,10 @@
 
     /* set point-to-point mode */
     c->mode = CM_P2P;
-
-    /* initialize tunnel instance */
-    init_instance_handle_signals(c, c->es, CC_HARD_USR1_TO_HUP);
+    /* initialize tunnel instance, avoid SIGHUP when config is stdin since
+     * re-reading the config from stdin will not work */
+    bool stdin_config = c->options.config && (strcmp(c->options.config, "stdin") == 0);
+    init_instance_handle_signals(c, c->es, stdin_config ? 0 : CC_HARD_USR1_TO_HUP);
     if (IS_SIG(c))
     {
         return;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/533?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icfc179490d6821e22d14817941fb0bad667c713f
Gerrit-Change-Number: 533
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#10 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: Avoid SIGUSR1 to SIGHUP remapping when the configuration is read from...

In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/533?usp=email )

Change subject: Avoid SIGUSR1 to SIGHUP remapping when the configuration is read from stdin
......................................................................

Avoid SIGUSR1 to SIGHUP remapping when the configuration is read from stdin

If the configuration is read from stdin, we cannot reread the configuration as stdin provides the configuration only once. So whenever we hit the "close_context usr1 to hup" logic, the OpenVPN process will fail as tries to restart with an empty configuration.

While OpenVPN tries to block USR1 from normal unix signal, I have observed cases in my app which sends USR1 from management interface where the CC_HARD_USR1_TO_HUP logic is trigger and breaking the OpenVPN process.

Change-Id Icfc179490d6821e22d14817941fb0bad667c713f

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28941.html

---
M src/openvpn/openvpn.c

1 file changed, 5 insertions(+), 3 deletions(-)
src/openvpn/openvpn.c +5 -3
index 0e85ebc..16147b7 100644
@@ -32,6 +32,7 @@
 #include "multi.h"
 #include "win32.h"
 #include "platform.h"
+#include "string.h"
 
 #include "memdbg.h"
 
@@ -60,9 +61,10 @@
 
     /* set point-to-point mode */
     c->mode = CM_P2P;
-
-    /* initialize tunnel instance */
-    init_instance_handle_signals(c, c->es, CC_HARD_USR1_TO_HUP);
+    /* initialize tunnel instance, avoid SIGHUP when config is stdin since
+     * re-reading the config from stdin will not work */
+    bool stdin_config = c->options.config && (strcmp(c->options.config, "stdin") == 0);
+    init_instance_handle_signals(c, c->es, stdin_config ? 0 : CC_HARD_USR1_TO_HUP);
     if (IS_SIG(c))
     {
         return;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/533?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icfc179490d6821e22d14817941fb0bad667c713f
Gerrit-Change-Number: 533
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged